#ifndef __LIST_H__
#define __LIST_H__
/////////////////
//include
/////////////////

/////////////////
//const
/////////////////

/////////////////
//class
/////////////////
template<class LIST_TYPE>
class List
{
	public:
	class ListMember
	{
	public:
		ListMember(LIST_TYPE* object,List<LIST_TYPE>* list)
		{
			this->object = object;
			this->list = list;
			next = NULL;
			pre = NULL;
		}
		~ListMember()
		{

		}
		void Delete()
		{
			
			if(pre == NULL&&next == NULL)
			{
				list->first = NULL;
				list->last = NULL;
				delete this;
				return;
			}
			if(pre == NULL)
			{
				list->first = next;
				list->first->pre = NULL;
				delete this;
				return;
			}
			if(next == NULL)
			{
				pre->next = NULL;
				list->last = pre;
				delete this;
				return;
			}
			next->pre = pre;
			pre->next = next;
			delete this;
		}
		LIST_TYPE* object;
		ListMember* next;
		ListMember* pre;
		List<LIST_TYPE>* list;
	private:

	};



	List()
	{
		first = NULL;
		last =NULL;
		now_select_member = NULL;
	}
	~List()
	{
	}
	void Set(LIST_TYPE* list)
	{
		ListMember* tmp_list_member = new ListMember(list,this);
		if(first == NULL)
		{
			first = tmp_list_member;
			last = first;
			return;
		}
		last->next = tmp_list_member;
		tmp_list_member->pre = last;
		last = last->next;
		
	}
	void SetFirst()
	{
		now_select_member = first;
	}
	ListMember* Get()
	{
		if(now_select_member == NULL)
			return NULL;
		ListMember* tmp_now_select_member = now_select_member;
		now_select_member = now_select_member->next;
 		return tmp_now_select_member; 
	}
	ListMember* first;
	ListMember* last;
	ListMember* now_select_member;
};
#endif __LIST_H__
